#coding=utf-8
#Boa:Dialog:DlgTableSale

import wx

from product import CDataTableSale

def create(parent):
    return DlgTableSale(parent)

[wxID_DLGTABLESALE, wxID_DLGTABLESALEBTNCANCEL, wxID_DLGTABLESALEBTNCONFIRM, 
 wxID_DLGTABLESALECHECKBUYER, wxID_DLGTABLESALECHECKDEBT, 
 wxID_DLGTABLESALECHECKPHONE, wxID_DLGTABLESALETCFOOTER, 
 wxID_DLGTABLESALETCTITLE, wxID_DLGTABLESALETFOOTER, wxID_DLGTABLESALETTITLE, 
] = [wx.NewId() for _init_ctrls in range(10)]

class DlgTableSale(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_DLGTABLESALE, name=u'DlgTableSale',
              parent=prnt, pos=wx.Point(435, 230), size=wx.Size(757, 429),
              style=wx.DEFAULT_DIALOG_STYLE,
              title=u'\u6253\u5370\u62a5\u8868--\u9500\u552e\u5355')
        self.SetClientSize(wx.Size(749, 395))
        self.Center(wx.BOTH)

        self.tTitle = wx.StaticText(id=wxID_DLGTABLESALETTITLE,
              label=u'\u62a5\u8868\u6807\u9898\uff1a', name=u'tTitle',
              parent=self, pos=wx.Point(48, 24), size=wx.Size(60, 14), style=0)

        self.tFooter = wx.StaticText(id=wxID_DLGTABLESALETFOOTER,
              label=u'\u62a5\u8868\u9875\u811a\uff1a', name=u'tFooter',
              parent=self, pos=wx.Point(48, 72), size=wx.Size(60, 14), style=0)

        self.tcTitle = wx.TextCtrl(id=wxID_DLGTABLESALETCTITLE, name=u'tcTitle',
              parent=self, pos=wx.Point(120, 16), size=wx.Size(328, 22),
              style=0, value=u'')

        self.tcFooter = wx.TextCtrl(id=wxID_DLGTABLESALETCFOOTER,
              name=u'tcFooter', parent=self, pos=wx.Point(120, 72),
              size=wx.Size(584, 120), style=wx.TE_MULTILINE, value=u'')

        self.btnConfirm = wx.Button(id=wxID_DLGTABLESALEBTNCONFIRM,
              label=u'\u786e\u5b9a', name=u'btnConfirm', parent=self,
              pos=wx.Point(176, 304), size=wx.Size(75, 24), style=0)
        self.btnConfirm.Bind(wx.EVT_BUTTON, self.OnBtnConfirmButton,
              id=wxID_DLGTABLESALEBTNCONFIRM)

        self.btnCancel = wx.Button(id=wxID_DLGTABLESALEBTNCANCEL,
              label=u'\u53d6\u6d88', name=u'btnCancel', parent=self,
              pos=wx.Point(448, 304), size=wx.Size(75, 24), style=0)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.OnBtnCancelButton,
              id=wxID_DLGTABLESALEBTNCANCEL)

        self.checkBuyer = wx.CheckBox(id=wxID_DLGTABLESALECHECKBUYER,
              label=u'\u662f\u5426\u6253\u5370\u91c7\u8d2d\u5458\u4fe1\u606f',
              name=u'checkBuyer', parent=self, pos=wx.Point(48, 208),
              size=wx.Size(144, 14), style=0)
        self.checkBuyer.SetValue(False)

        self.checkDebt = wx.CheckBox(id=wxID_DLGTABLESALECHECKDEBT,
              label=u'\u662f\u5426\u6253\u5370\u6b20\u6b3e\u603b\u91d1\u989d',
              name=u'checkDebt', parent=self, pos=wx.Point(48, 256),
              size=wx.Size(248, 14), style=0)
        self.checkDebt.SetValue(False)

        self.checkPhone = wx.CheckBox(id=wxID_DLGTABLESALECHECKPHONE,
              label=u'\u662f\u5426\u6253\u5370\u516c\u53f8\u7535\u8bdd',
              name=u'checkPhone', parent=self, pos=wx.Point(48, 232),
              size=wx.Size(216, 14), style=0)
        self.checkPhone.SetValue(True)

    def __init__(self, parent):
        self._init_ctrls(parent)

        self.myInit()
        
    def myInit(self):
        self.tblSale = CDataTableSale.getTableSale()
        
        self.tcTitle.SetValue(self.tblSale.getValue(CDataTableSale.iTitle))
        self.tcFooter.SetValue(self.tblSale.getValue(CDataTableSale.iFooter))
        
        self.checkBuyer.SetValue(CDataTableSale.includeBuyer())
        self.checkDebt.SetValue(CDataTableSale.includeDebt())
        self.checkPhone.SetValue(CDataTableSale.includePhone())
                
    def OnBtnConfirmButton(self, event):
        title = self.tcTitle.GetValue()
        footer = self.tcFooter.GetValue()
        CDataTableSale.updateData(title, footer, self.checkBuyer.GetValue(),
                                    self.checkDebt.GetValue(), 
                                    self.checkPhone.GetValue())
        self.Close()

    def OnBtnCancelButton(self, event):
        self.Close()
